import java.io.FileInputStream;
import java.security.MessageDigest;
import java.sql.DatabaseMetaData;

import javax.swing.JOptionPane;

public class md5
{	
	public static String salt = "2011"; 
	
	public static String getMD5(String str)
	{
		try
		{	    	 
			str += salt;
	        MessageDigest md = MessageDigest.getInstance("MD5");
	        md.update(str.getBytes());
	 
	        byte byteData[] = md.digest();
	 
	        //convert the byte to hex format method 1
	        StringBuffer sb = new StringBuffer();
	        for (int i = 0; i < byteData.length; i++) {
	         sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
	        }
	        
	        return sb.toString();
		}
		catch(Exception e)
		{
			JOptionPane.showMessageDialog(glowna.mw, e.getMessage());
		}
		return null;
	}
	
	/*
    public static void main(String[] args)throws Exception
    {
        System.out.println(get_MD5("abc"));
        System.out.println(get_MD5("222"));
    }
    */
}